<?php
//初始化奖品库存
ini_set('display_errors', 1);
error_reporting(-1);
require_once '/data/wwwroot/g_vendor/autoload.php';

$data = [
    ['id' => 1, 'goods_name' => '小米小爱音箱 Pro', 'price' => 299.00, 'stock' => 20, 'data_status' => 1],
    ['id' => 2, 'goods_name' => '小米烟感卫士', 'price' => 149.00, 'stock' => 10, 'data_status' => 1],
    ['id' => 3, 'goods_name' => '小米天然气卫士', 'price' => 179.00, 'stock' => 10, 'data_status' => 1],
];

foreach ($data as $item){
    $prize = \Biz\model\MijiaSmartKitchen\MiJiaSmartKitchenPrize::dataSelectInfo(['id'=>$item['id']]);
    if($prize){
        \Biz\model\MijiaSmartKitchen\MiJiaSmartKitchenPrize::dataUpdate(['stock'=>$item['stock'],'stock_version'=>0],['id'=>$item['id']]);
    }else{
        \Biz\model\MijiaSmartKitchen\MiJiaSmartKitchenPrize::dataInsert($item);
    }
}

var_dump(\Biz\model\MijiaSmartKitchen\MiJiaSmartKitchenPrize::log());





